from mission_7_30_1.Page.Page1 import Page1
from selenium.webdriver.common.by import By
class Page2(Page1):
    # 点击首页
    home_loc=(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a')
    def home(self):
        self.click(self.home_loc)
    # 搜索商品和回车事件
    search_loc=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')
    def search(self):
        self.send_keys(self.search_loc,'手机')
        self.Enter(self.search_loc)
    # 点击商品
    goods_loc=(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[1]/div[1]/span/a/img')
    def goods(self):
        self.click(self.goods_loc)


    # 清空并修改商品数量
    nums_loc=(By.XPATH,'//*[@id="store_nums"]')
    def nums(self):
        self.clear(self.nums_loc)
        self.send_keys(self.nums_loc,'2')
    # 点击立即购买
    buy_loc=(By.ID,'buy-cart')
    def buy(self):
        self.click(self.buy_loc)
    # 点击下一步
    next_loc=(By.ID,'order-button')
    def next(self):
        self.click(self.next_loc)
    # 断言5 订单完成
    dy5_loc=(By.LINK_TEXT,'订单完成')
    def dy5(self):
        return self.text(self.dy5_loc)
    # 查看订单
    dianji_loc=(By.XPATH,'/html/body/div[4]/div[3]/p/a')
    def dianji(self):
        self.click(self.dianji_loc)
    # 断言4 商品单价
    dy4_loc = (By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/table[1]/tbody/tr/td[3]')

    def dy4(self):
        return self.text(self.dy4_loc).replace('￥','')

    def A3mall_search(self):
        self.A3mall_login()
        # self.open_url('http://10.59.9.12:7001/')
        self.home()
        self.search()
        self.goods()

        self.nums()
        self.buy()
        self.next()
        self.dy5()
        print(self.dy5())
        self.dianji()
        self.dy4()
        print(self.dy4())
